import os, sys

sys.path.append(os.getcwd())
from common.settings import _print


def f1(attributes, values):
    res = []
    for item in values:
        dict = {}
        for idx, attr in enumerate(attributes):
            dict[attr] = item[idx]
        res.append(dict)
    _print(res)


def f2(attributes, values):
    _print([{attr: item[idx] for idx, attr in enumerate(attributes)} for item in values])
    # _print(res)


def main():
    attributes = ['name', 'dob', 'gender']
    values = [['jason', '2000-01-01', 'male'],
              ['mike', '1999-01-01', 'male'],
              ['nancy', '2001-02-01', 'female']
              ]
    # expected output:
    """
    [{'name': 'jason', 'dob': '2000-01-01', 'gender': 'male'},
     {'name': 'mike', 'dob': '1999-01-01', 'gender': 'male'},
     {'name': 'nancy', 'dob': '2001-02-01', 'gender': 'female'}]
    """
    # f1(attributes, values)
    f2(attributes, values)


def t10():
    d = {'mike': 10, 'lucy': 2, 'ben': 30}
    d2 = sorted(d.items(), key=lambda x: x[1], reverse=True)
    _print(d2)


def t050301():
    l1 = [1, 2, 3]
    l2 = [1, 2, 3]
    l3 = l2
    _print(id(l1), id(l2), id(l3))

    def func(d):
        d['a'] = 10
        d['b'] = 20

    d = {'a': 1, 'b': 2}
    func(d)
    _print(d)





if __name__ == '__main__':
    pass
